<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>

    <body>
        <button>Click me any way you want</button>
        <script>
            let button = document.querySelector("button");
            button.addEventListener("mousedown", event => {
                if (event.button == 0) {
                    console.log("Left button");
                } else if (event.button == 1) {
                    console.log("Middle button");
                } else if (event.button == 2) {
                    console.log("Right button");
                }
            });
        </script>

    </body>

</html>